<template>
  <div>
    <h1>登录</h1>
    <table>
      <tr>
        <td>账号</td>
        <td><input type="text" v-model="ojbss.name" /></td>
      </tr>
      <tr>
        <td>密码</td>
        <td><input type="password" v-model="ojbss.pwd" /></td>
      </tr>
      <tr>
        <td></td>
        <td><input type="button" @click="login" value="登录" /></td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { ref, reactive } from "vue";
import { useRouter } from "vue-router";
const rou = useRouter();

let ojbss = reactive({
  name: "",
  pwd: "",
});

const login = () => {
  if (ojbss.name == "") {
    alert("账号不可为空");
    return;
  }
  if (ojbss.pwd == "") {
    alert("密码不可为空");
    return;
  }

  axios({
    url: "https://localhost:7071/api/User/Login",

    params: {
      name: ojbss.name,
      pwd: ojbss.pwd,
    },
  }).then((res) => {
    if (true) {
      alert("登录成功");
    }
    rou.push('/show');

  });
};
</script>

<style scoped></style>
